<template>
  <div>
    <div class="aside_box">
      <div class="aside_box_title">部门/科室目录</div>
      <el-tree
          :expand-on-click-node="clickNode"
          :default-expand-all="expandAll"
        :data="list"
        :props="defaultProps"
        node-key="id"
        @node-click="handleNodeClick"
      >
        <!-- 		  default-expand-all -->
      </el-tree>
    </div>
  </div>
</template>

<script setup lang="ts">
// let id = 1000;
export default {
  props: {
    list: {
      type: Array,
      required: true,
    },
    expandOnClickNode:{
      type: Boolean
    },
    defaultExpandAll:{
      type: Boolean,
      defalut : false
    }
  },
  data() {
    return {
      departmentList: [],
      defaultProps: {
        children: "children",
        label: "label",
      },
      clickNode:this.expandOnClickNode,
      expandAll:this.defaultExpandAll,
    };
  },
  watch: {
    // async list(val){
    //   val.map(item=>item.children=null)
    //   this.departmentList= val
    // }
  },
  created() {},
  mounted() {},
  methods: {
    handleCheck(data) {
      console.log(this.$refs.tree.store);
      this.$refs.tree.store.nodesMap[data.id].expanded = true;
      data.unfold = true;
    },
    handleNodeClick(data) {
      this.$emit("getcatatlogue", data);
    },
  },
};
</script>

<style scoped>

.el-date-editor.el-input {
  /* width: 50%; */
}

.header_top .el-divider--horizontal {
  margin-top: 12px;
}

.el-main {
  padding: 0px;
  padding-left: 20px;
}

.aside_box {
  /* height: 100%; */
  background: #fff;
  padding-top: 10px;
}

.aside_box_title {
  margin: 0px 8px 10px;
  /* text-align: center; */
}

.main_box_title {
  background: #fff;
  padding: 10px;

}

.el-tree {
  padding-bottom: 20px;
}

.custom-tree-node {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  padding-right: 8px;
}
</style>
